from typing import *

class Solution:
    def minSum(self, nums1: List[int], nums2: List[int]) -> int:
        s1,s2=sum(nums1),sum(nums2)
        c1,c2=Counter(nums1),Counter(nums2)
        if c2[0] > 0 and c1[0] > 0:
            return max(s1+c1[0],s2 + c2[0])
        if s2 + c2[0] <= s1  and c2[0] > 0:
            return s1
        if s1 + c1[0] <= s2  and c1[0] > 0:
            return s2 
        if c1[0] == 0 and c2[0] == 0 and s1 == s2:
            return s1
        return -1


s = Solution()
print(s.minSum([10,4,24,2,17,10,0,29,3,0,19,7,24,17,30,7],
[1,0,13,0,0,28,0,23,24,13,4,30,8,4,0,1,29,25]))
print(s.minSum(nums1 = [3,2,0,1,0], nums2 = [6,5,0]))